import { http } from '@/utils/request'
import type { OrderParams, PageParams, UpdateOrderStatusParams, RefundParams } from "@/types/order"

// 创建订单
export const createOrder = (data: OrderParams) => {
    return http({
        method: 'POST',
        url: '/app-api/customer/order/create',
        data,
    })
}
// 查询订单详情
export const getOrderDetail = (id: string) => {
    return http({
        method: 'GET',
        url: '/app-api/customer/order/get',
        data: {
            id
        }
    })
}
// 获得待接单列表分页
export const getWaitOrderPage = (data: PageParams) => {
    return http({
        method: 'GET',
        url: '/app-api/customer/order/getWaitOrderPage',
        data
    })
}
// 获得已接单列表分页
export const getAcceptOrderPage = (data: PageParams) => {
    return http({
        method: 'GET',
        url: '/app-api/customer/order/getAcceptOrderPage',
        data
    })
}
// 取消订单
// export const updateOrder = (data: UpdateOrderStatusParams) => {
//     return http({
//         method: 'PUT',
//         url: '/app-api/customer/order/refundOrder',
//         data
//     })
// }
// 退款
export const refundOrder = (data: RefundParams) => {
    return http({
        method: 'DELETE',
        url: `/app-api/customer/order/refundOrder?id=${data.id}&refundPrice=${data.refundPrice}`,
    })
}
// 加价
export const addPrice = (data: any) => {
    return http({
        method: 'POST',
        url: '/app-api/customer/order/addPrice',
        data
    })
}
// 刷新支付单
export const refreshPayOrder = () => {
    return http({
        method: 'GET',
        url: '/app-api/customer/order/refreshPayOrder'
    })
}
// 创建评论
export const createComment = (data: any) => {
    return http({
        method: 'POST',
        url: '/app-api/customer/comment/addCommentDone',
        data
    })
}